package org.example.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/api")
@Api(tags = "公共API")
public class PublicController {

    @GetMapping("/hello")
    @ApiOperation(value = "测试接口", notes = "这是一个测试接口，用于返回Hello消息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "用户姓名", required = false, defaultValue = "World", paramType = "query")
    })
    public String hello(@RequestParam(required = false, defaultValue = "World") String name) {
        return String.format("Hello, %s!", name);
    }

    @PostMapping("/upload")
    @ApiOperation(value = "文件上传接口", notes = "支持单个文件上传")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "file", value = "上传的文件", required = true, paramType = "formData", dataType = "file")
    })
    public String uploadFile(@RequestParam("file") MultipartFile file) {
        // 文件处理逻辑
        return "File uploaded successfully!";
    }
}
